//
//  ZXUIViewExtension.swift
//  ExtensionTest
//
//  Created by ZX on 2025/2/10.
//

import UIKit

public extension UIView {
    func updateLayout() {
        UIView.animate(withDuration: 0.3) {
            self.superview?.layoutIfNeeded()
        }
    }
    func removeAllSubviews() {
        subviews.forEach { $0.removeFromSuperview() }
    }
    func addSubViews(_ arr : [UIView]) {
        for view in arr {
            self.addSubview(view)
        }
    }
    var isShow : Bool {
        set{
            self.isHidden = !newValue
        }
        get{
            !self.isHidden
        }
    }
    var cornerRadius: CGFloat {
        get {
            return layer.cornerRadius
        }
        set(newValue) {
            layer.cornerRadius = newValue
            layer.masksToBounds = true
        }
    }
    func border(_ width: CGFloat,_ color: UIColor){
        layer.borderWidth = width
        layer.borderColor = color.cgColor
    }
}

//////
//public extension UIView {
//    var origin: CGPoint {
//        get { return frame.origin }
//        set { frame.origin = newValue }
//    }
//
//    var top: CGFloat {
//        get { return frame.origin.y }
//        set { frame.origin = CGPoint(x: frame.origin.x, y: newValue) }
//    }
//
//    var left: CGFloat {
//        get { return frame.origin.x }
//        set { frame.origin = CGPoint(x: newValue, y: frame.origin.y) }
//    }
//
//    var bottom: CGFloat {
//        get { return frame.origin.y + frame.height }
//        set { top = newValue - frame.height }
//    }
//
//    var right: CGFloat {
//        get { return frame.origin.x + frame.width }
//        set { left = newValue - frame.width }
//    }
//
//    var size: CGSize {
//        get { return bounds.size }
//        set { bounds.size = newValue }
//    }
//
//    var width: CGFloat {
//        get { return frame.width }
//        set { frame.size = CGSize(width: newValue, height: frame.height) }
//    }
//
//    var height: CGFloat {
//        get { return frame.height }
//        set { frame.size = CGSize(width: frame.width, height: newValue) }
//    }
//}


//public extension UIView {
//    func addTap(_ target: Any, _ action: Selector){
//        self.isUserInteractionEnabled = true
//        let tap = UITapGestureRecognizer()
//        self.addGestureRecognizer(tap)
//        tap.addTarget(target, action: action)
//    }
//    func addLongPress(_ target: Any, _ action: Selector) {
//        self.isUserInteractionEnabled = true
//        let longProgress = UILongPressGestureRecognizer()
//        self.addGestureRecognizer(longProgress)
//        longProgress.addTarget(target, action: action)
//    }
//}


